<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="pmes" uri="http://www.pmes.com/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@include file="/WEB-INF/jsp/common/common.jsp"%>
	<script>
    $(function(){
    	$("#searchBtn").click(function(){
    		var rows = $('#dataTable').datagrid('getSelections');
    		if ( rows.length == 0 ) {
    			$.messager.alert('系统提示信息', "必须选择查看流程监控的故障单信息",'error');
    		} else if ( rows.length > 1 ) {
    			$.messager.alert('系统提示信息', "只能选择一条故障单信息查看流程监控",'error');
    		} else {
        		var row = rows[0];
        		$("#imgWindow").window("open");
        		$("#procMonitorImg").attr("src", "${APP_PATH}/proc/loadMonitorImg.do?id="+row.piid);
    		}
    	});
    	$("#assignBtn").click(function(){
    		var rows = $('#dataTable').datagrid('getSelections');
    		if ( rows.length == 0 ) {
    			$.messager.alert('系统提示信息', "必须选择需要审批的故障单信息",'error');
    		} else if ( rows.length > 1 ) {
    			$.messager.alert('系统提示信息', "只能选择一条故障单信息进行审批",'error');
    		} else {
        		var row = rows[0];
        		$("#authWindow").window("open");
        		$("#btLevel").text(row.levelLabel);
        		$("#btAddress").text(row.addressLabel);
        		$("#btRemark").text(row.remark);
        		$("#btHappentime").text(row.happentime);
        		$("#btCreatetime").text(row.createtime);
        		$("#btId").val(row.btid);
        		$("#taskId").val(row.id);
        		$("#piId").val(row.piid);
    		}
    	});
    });
    function submitUpdateForm() {
		$.messager.progress();
		$('#btUpdateForm').form('submit', {
	        onSubmit: function(){
	        	return true;
	        },
	        success : function( data ) {
	        	$.messager.progress('close');	
	        	var r = eval('(' + data + ')');
	        	if ( r.success ) {
					$.messager.alert('系统提示信息', "故障单信息修改成功",'info', function(){
						$('#dataTable').datagrid('reload');
						$('#btUpdateWindow').window('close');
					});
	        	} else {
	        		$.messager.alert('系统提示信息', "故障单信息修改失败",'error');
	        	}
	        }
		});
    }
	function submitForm(){
		$.messager.progress();
		$('#btForm').form('submit', {
	        onSubmit: function(){
	        	return true;
	        },
	        success : function( data ) {
	        	$.messager.progress('close');	
	        	var r = eval('(' + data + ')');
	        	if ( r.success ) {
					$.messager.alert('系统提示信息', "故障单信息审批成功",'info', function(){
						$('#dataTable').datagrid('reload');
						$('#authWindow').window('close');
					});
	        	} else {
	        		$.messager.alert('系统提示信息', "故障单信息审批失败",'error');
	        	}
	        }
		});
	} 
	</script>
</head>
<body class="easyui-layout">
    <div data-options="region:'center',border:false">
	<table id="dataTable"
	       class="easyui-datagrid"
	       title="待审故障单分页查询表格 "
		   data-options="
		        fit:true,
		        border:false,
		   		singleSelect:false,
		   		collapsible:false,
		   		fitColumns:true,
		   		rownumbers:true,
		   		url:'${APP_PATH}/bt/pageQueryAuth.do',
		   		method:'get',
				pagination:true,
				pageSize:10,
				toolbar:'#tb'
		   ">
		<thead>
			<tr>
			    <th data-options="field:'id',checkbox:true"></th>
				<th data-options="field:'remark',width:100">故障标题</th>
				<th data-options="field:'pdname',width:100">流程名称</th>
				<th data-options="field:'taskname',width:100">任务状态</th>
				<th data-options="field:'tasktime',width:100">接任时间</th>
				<th data-options="field:'username',width:100">建障人</th>
				<th data-options="field:'createtime',width:100">建障时间</th>
			</tr>
		</thead>
	</table>
	</div>
	<div id="tb" style="padding:5px;height:auto">
		<div style="margin-bottom:5px">
			<a href="#" id="searchBtn" class="easyui-linkbutton" iconCls="icon-search" plain="true"></a>
			<a href="#" id="assignBtn" class="easyui-linkbutton" iconCls="icon-redo" plain="true"></a>
		</div>
	</div>
	<div id="authWindow" class="easyui-window" title="故障单审批窗口"
	    data-options="
	        modal:true,
	        closed:true,
	        iconCls:'icon-redo'"
	    style="width:500px;height:400px;padding:10px;">
	    <form id="btForm" action="${APP_PATH}/bt/doAuth.do" method="post">
		<input type="hidden" name="btid" id="btId">
		<input type="hidden" name="taskid" id="taskId">
		<input type="hidden" name="piid" id="piId">
		<table border="0" cellpadding="0" cellspacing="0" class="box_table" id="box_table2">
		          <thead>
		            <tr>
		              <td class="box_table_even">故障级别：</td>
		              <td class="box_table_odd"><span id="btLevel"></span></td>
		            </tr>
		            <tr>
		              <td class="box_table_even">故障局点：</td>
		              <td class="box_table_odd"><span id="btAddress"></span></td>
		            </tr>
		            <tr>
		              <td class="box_table_even">故障描述：</td>
		              <td class="box_table_odd"><span id="btRemark"></span></td>
		            </tr>
		            <tr>
		              <td class="box_table_even">故障发生时间：</td>
		              <td class="box_table_odd"><span id="btHappentime"></span></td>
		            </tr>
		            <tr>
		              <td class="box_table_even">建障时间：</td>
		              <td class="box_table_odd"><span id="btCreatetime"></span></td>
		            </tr>
		            <tr>
		              <td class="box_table_even">审批备注：</td>
		              <td class="box_table_odd">
		                   <textarea name="remark" rows="5" cols="20"></textarea>
		              </td>
		            </tr>
		          </thead>
		          <tbody>
		          </tbody>
		        </table>
		        </form>
	    <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">同意</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">返回</a>
	    </div>
	</div>
	<div id="imgWindow" class="easyui-window" title="流程监控窗口"
	    data-options="
	        modal:true,
	        closed:true,
	        iconCls:'icon-search'"
	    style="width:500px;height:500px;padding:10px;">
        <img id="procMonitorImg" src="${APP_PATH}/images/loading.gif" />
	</div>	
</body>
</html>
